Compile MAME with Clang 22 or GCC 16 on Windows 10/11
=====================================================

This is a guide to compile the newest MAME version. Simply start a script and you can compile a 32bit version for Windows XP or a 64bit for Windows 10/11.
For different MAME versions (ARCADE or MESS) the necessary files arcade.flt and mess.flt will be auto-generated. No need to do this by hand!


* First download the newest MSYS2 installer (msys2-x86_64-2025...exe) at https://github.com/msys2/msys2-installer/releases/ or https://www.msys2.org/
  If you have a "SetThreadDescription" error use the older MSYS2 installer msys2-x86_64-20241208.exe.
  Make sure you are connected to the internet!!! Double-click on the installer, enter your desired installation folder and press 'Next'.
  The default location of the MSYS2 installation is C:\msys64. If you don't have Administrator rights, you can install MSYS2 in any location
  you have access to, e.g. C:\Users\'user'\msys64 (with 'user' being your Windows user directory name).
  When done, click Finish. A terminal for the UCRT64 environment will launch. 
  Type/Paste   pacman -Syu --noconfirm     into the terminal to update MSYS. The terminal close automatically or close it.

* Go into the msys64 directory and create a desktop shortcut for:
  'mingw32.exe' (GCC/Clang 32bit version)
  'clang64.exe' (Clang 64bit version)
  'ucrt64.exe' (GCC 64bit version)
  with right click on the program and choose "Send to, Desktop (Create Shortcut)". Start the shortcut.
  Changed the default size of the Window with right mouse button ("Options..." and "Window") to Columns=135 and Rows=35 and press "Apply" and "Save".
  Set the font size ("Text" and "Select...") to 11.

* Now setup the compiler with one of the following commands:
  "32bit" MAME version: Copy the files  'init-XP32.sh' and  'XPackage.zip'  into  msys64\tmp.     Type/Paste   bash -l /tmp/init-XP32.sh
  "64bit" MAME version: Copy the files  'init.sh'      and  'XPackage.zip'  into  msys64\tmp.     Type/Paste   bash -l /tmp/init.sh

* The script download now the compiler tools and after that the newest MAME source and extract it. After the script is finish you can go offline!
  ***Ignore the 2x ERRORs "mame-master\3rdparty\zstd\tests\cli-tests\bin\unzstd + zstdcat". 7zip cannot extract 0 Bytes files unzstd + zstdcat.

* Restart the mingw launcher and type/paste  make -j5  into the console to compile a *full* MAME verion.


Speed up compiling process with (-j) option
-------------------------------------------
make -j3          (3x files; Dual Core CPU and 4GB RAM)
make -j5          (5x files; Quad Core and 8GB RAM)
make -j7          (7x files; Six Core and > 16GB RAM)
.
.
.

Compile different MAME versions
-------------------------------
MAME                  make -j5
ARCADE                make -j5 SUBTARGET=arcade
MESS                  make -j5 SUBTARGET=mess
TINYMAME              make -j5 SUBTARGET=tinymame SOURCES=src/mame/???/ANY--DRIVER--YOU--WANT.cpp
  TINYMAME-Example    make -j5 SUBTARGET=tinymame SOURCES=src/mame/namco/rallyx.cpp
ARCADE MAMEUI         make -j5 OSD=winui SUBTARGET=arcade     NOTE: This version needs the extra winui files from https://github.com/Robbbert/mameui



Note (1): If you compile MAME for the first time try a TINYMAME version with only one driver. Compiling time is very short and you get a MAME version for testing !!!
Note (2): If you compile a 32bit MAME version with Clang ignore the several error messages at the end of the Linking process. This is a MAME source problem:
---->     libstdc++.a(bad_alloc.o): duplicate section `.rdata$_ZTSSt9exception[__ZTSSt9exception]' has different size



The final 32bit/64bit MAME file
-------------------------------
The final  mame.exe  or  tinymame.exe  can you find in the folder  msys64\tmp\mame-master
To use it you need some extra files that are in the latest MAME version from https://www.mamedev.org/release.html
Download this file and extract all files in a directory of your choice and replace the
mame.exe with your new compiled MAME version (32bit or 64bit).

Now open a command prompt and jump into your MAME directory and type/paste:  mame.exe -cc
to generate the ini-files:  mame.ini,  plugin.ini  and  ui.ini.
Move these files into the MAME/ini directory and make the following changes
to the mame.ini with an editor:

inipath                   ini;ini/presets
snapbilinear              0
maximize                  0
filter                    0

... and for the Windows XP 32bit version:

keyboardprovider          dinput
mouseprovider             dinput
video                     d3d
sound                     dsound

Copy a game for example rallyx.zip into the rom directory and start MAME to test it!





Compile a new/updated MAME version
----------------------------------
Copy the file  'git.sh'  for 64bit  or  'git-XP32.sh'  for 32bit into msys64\tmp
to download the newest MAME source, patch the source and compile it.
Connect to the internet and type/paste the following commands into the console:

bash -l /tmp/git.sh   or   bash -l /tmp/git-XP32.sh
cd mame-master
make



Compile the official MAME source
--------------------------------
Copy the file  'patch64.sh' for 64bit  or  'patchXP32.sh' for 32bit into msys64\tmp
Download the official MAME source from https://www.mamedev.org/release.php
Delete the old source folder  mame-master  in the msys64\tmp directory.
Create a new  mame-master  folder and extract the official source into it!
Connect to the internet and type/paste the following commands into the console:

bash -l /tmp/patch64.sh   or   bash -l /tmp/patchXP32.sh
cd mame-master
make



Keyboard shortcuts
------------------

CTRL+C    : Break compiling process
Up/Down   : Hold up last/next line
Shift+PgUp: Page up
Shift+PgDn: Page down
Shift+Home: Top
Shift+End : Bottom 
Alt+Enter : Toggle between Window Menu and Full Screen
Alt+F2    : New window
Alt+F3    : Search (in scrollback buffer)
ALT+F4    : Exit/Close window. Or you click on the window's close button or choose 'Close' from the window menu.
Alt+F8    : Reset

More shortcuts: https://mintty.github.io/mintty.1.html



Compile Tools
-------------
In the Tools directory you can find useful batch files for compiling. Before you can use
these batch files you must edit the files to correct the working directory.

'0-Byte-Deleting.bat': Deletes 0 byte files in MAME's build directory
'CP.bat'             : Compile MAME without the console. Don't forget to start msys64\autorebase.bat and
                       edit the CP.bat to correct the MingW location.
'DOB.bat'            : Deletes specific object files in the build directory


---------------------------------------------------------------------------------------------------------------------

History:

- 30th May       2024: Updated arcade+mess-flt.bat, exceptions(arcade).txt and exceptions(mess).txt. Fixed Clang init-XP32.sh script.
- 15th April     2026: Updated Clang and GCC 32bit scripts.
- 14th April     2026: Updated Clang and GCC scripts.
- 12th April     2026: Switch 64bit GCC init.sh scripts from MSVCRT to UCRT. Create a Clang64 scripts with MSYS2 mingw-w64-clang packages.
-  5th April     2026: Fixed init-XP32.sh Clang script (MSYS2 server can't find any packages).
-  4th April     2026: Fixed init-XP32.sh, git-XP32.sh and patchXP32.sh scripts for Windows XP (GetPointerInfo + EnableMouseInPointer missing in user32.dll).
- 25th January   2026: Fixed arcade+mess-flt.bat and exceptions(arcade).txt.
- 26th November  2025: Fixed exceptions(arcade).txt and exceptions(mess).txt.
- 28th July      2025: Fixed exceptions(mess).txt.
-  5th July      2025: Updated README.TXT.
-  4th July      2025: Fixed Clang scripts (missing mingw-w64-i686-llvm package). Re-added DirectSound to init-XP32.sh, git-XP32.sh and patchXP32.sh.
- 21st April     2025: Fixed Clang scripts (ImGui update -> No more Clang 20.1 warnings). Updated exceptions(arcade).txt and exceptions(mess).txt.
-  2nd April     2025: Fixed Clang scripts (Clang 20.1 warning: first argument in call to 'memset' is a pointer to non-trivially copyable type).
- 15th February  2025: Updated exceptions(arcade).txt. Added missing 'GetLogicalProcessorInformation' patch to init-XP32.sh, git-XP32.sh and patchXP32.sh.
- 18th November  2024: Updated arcade+mess-flt.bat and this README.TXT.
-  3rd September 2024: Updated arcade+mess-flt.bat.
- 25th August    2024: Updated exceptions(arcade).txt and exceptions(mess).txt.
- 16th May       2024: Updated exceptions(mess).txt.
- 10th May       2024: Updated exceptions(arcade).txt and README.TXT. Changed 'Scripts' directory names.
-  7th May       2024: MAME's LUAengine/SOL2 problem was solved. Updated Clang script for Clang 18.1.x. MSYS2 newest version is msys2-x86_64-20240507.exe!
- 12th April     2024: Added MSYS2 installation Administrator rights info to README.TXT.
- 10th April     2024: Updated the Clang compile scripts to use Clang 17.0.6 (Clang 18.1.x doesn't work!).
-  4th April     2024: Fixed GCC scripts init-XP32.sh and init.sh.
- 28th March     2024: Added scripts for GCC 13.2.0.
- 25th March     2024: Updated exceptions(arcade).txt and exceptions(mess).txt.
-  9th March     2024: Updated init.sh, git.sh scripts and arcade+mess-flt.bat.
- 19th October   2023: Updated arcade+mess-flt.bat, exceptions(arcade).txt and exceptions(mess).txt.
- 25th June      2023: Updated exceptions(arcade).txt and exceptions(mess).txt.
- 13th June      2023: Updated exceptions(arcade).txt.
- 31st May       2023: Updated exceptions(arcade).txt.
- 13th May       2023: Updated arcade+mess-flt.bat. 
- 28th April     2023: Added missing patch64.sh script (thanks to Jets). Also txt and script corrections (remove TARGET=mame).
-  5th April     2023: Correct arcade- and mess.flt files.
-  3rd April     2023: Correct ini.sh script and README.TXT.

---------------------------------------------------------------------------------------------------------------------

Do you still have questions, then email to: mameinfo@ewetel.net


(c) 2026 MASH

